<template>
<div class="">
    <div class="pr10">
        <div class="analyItem">
            <p class="analyItemTit tx-center">状态</p>
            <div class="analyItemCon">
                <!-- <span class="circlemark circlemark-lightRed">差</span> -->
            </div>
        </div>
    </div>
    <div class="thinScroll pr10" v-scrollHeight="84">
        <router-link exact tag="div" v-for="(item,index) in workList" :key="index" :to="{path:routerPath('itemThree'), query:{orderno:item.orderno}}" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center" :data-title="item.proname">{{item.proname | ellipsis(4)}}</p>
            <div class="analyItemCon">
                <p class="col-md-4" >
                    <span class="pr8 cLightGray">单号</span>
                    <!-- {{(completmet.thisMonthCompletedRate * 100).toFixed(2)}}% -->
                    <span>{{item.orderno}}</span>
                </p>
                <p class="col-md-4" >
                    <span class="pr8 cLightGray">应完工</span>
                    <span>{{item.finishTime | ellipsis(10)}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">阶段</span>
                    <span class="">{{item.type}}</span>
                </p>
            </div>
        </router-link>
    </div>
    <div class="pr10">
        <!-- <router-link tag="div" :to="routerPath('resultProcessing')" class="analyItem anItemBor" active-class="anItemBor-active"> -->
            <div class="analyItem">
            <p class="analyItemTit tx-center">处理</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="pr8 cLightGray">共计</span>
                    <span>{{workList.length}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">在施</span>
                    <span>{{workingTotal.length}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">竣工</span>
                    <span>{{completedTotal.length}}</span>
                </p>
            </div>
            </div>
        <!-- </router-link> -->
    </div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import { findWorkOrderByAreaId } from '../Resources/Api'
export default {
    data () {
        return {
            workList: [], // list
            workingTotal: [],
            completedTotal: []

        }
    },
    created () {
        this.findWorkOrderByAreaId()
    },
    computed: {
        ...mapGetters(['userInfo', 'leftInfo'])
    },
    methods: {
        findWorkOrderByAreaId () {
            findWorkOrderByAreaId({
                areaId: this.leftInfo.as_u_diqu// 22
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.workList = res.data.Body
                    this.workingTotal = this.workList.filter(item => item.type === '竣工')
                    this.completedTotal = this.workList.filter(item => item.type !== '竣工')
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        }
    },
    watch: {
        leftInfo () {
        },
        $route () {
            this.findWorkOrderByAreaId()
        }
    },
    filters: {
        ellipsis (value, num) {
            if (!value) return ''
            if (value.length > num) {
                return value.slice(0, num) + ''
            }
            return value
        }
    }
}
</script>
